/*************************************************************************
	> File Name: audio.c
	> Author: 
	> Mail: 
	> Created Time: 2018年11月01日 星期四 15时07分52秒
 ************************************************************************/
#include "audio.h"
#include <stdlib.h>
#include <string.h>
#define CMD_ERR 127

int AudioPlay(char * path)
{
    int err = 0;
    if(NULL == path)
    {
        printf("AudioPlay:please enter the path\r\n");
        return 0;
    }
    char *p = (char *)malloc(strlen(path+7));
    char *ptr = p;
    if(NULL == p)
    {
        printf("AudioPlay:malloc error\r\n");
        return -1;
    }
    strcpy(p,"aplay ");
    strcat(p,path);
    err = system(p);
    free(ptr);
    ptr = NULL;
    p = NULL;
    if(CMD_ERR == err)
    {
        printf("AudioPlay:shell startup failed\r\n");
        return -1;
    }
    if(-1 == err)
    {
        printf("AudioPlay:unknow mistake\r\n");
    }
    return 0;
}

